<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>pthread_join</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_000_007_1378">&nbsp;</a>NAME</h4><blockquote>
pthread_join - wait for thread termination
</blockquote><h4><a name = "tag_000_007_1379">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

#include &lt;<a href="pthread.h.html">pthread.h</a>&gt;

int pthread_join(pthread_t <i>thread</i>, void **<i>value_ptr</i>);
</code>
</pre>
</blockquote><h4><a name = "tag_000_007_1380">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i>pthread_join()</i>
function suspends execution of the calling thread until the target
<i>thread</i>
terminates, unless the target
<i>thread</i>
has already terminated.
On return from a successful
<i>pthread_join()</i>
call with a non-NULL
<i>value_ptr</i>
argument, the value passed to
<i><a href="pthread_exit.html">pthread_exit()</a></i>
by the terminating thread is made available in the location referenced by
<i>value_ptr</i>.
When a
<i>pthread_join()</i>
returns successfully, the target thread has been terminated.
The results of multiple simultaneous calls to
<i>pthread_join()</i>
specifying the same target thread are undefined.
If the thread calling
<i>pthread_join()</i>
is canceled, then the target thread will not be detached.
<p>
It is unspecified whether a thread that has exited but remains unjoined
counts against _POSIX_THREAD_THREADS_MAX.
</blockquote><h4><a name = "tag_000_007_1381">&nbsp;</a>RETURN VALUE</h4><blockquote>
If successful, the
<i>pthread_join()</i>
function returns zero.
Otherwise, an error number is returned to indicate the error.
</blockquote><h4><a name = "tag_000_007_1382">&nbsp;</a>ERRORS</h4><blockquote>
The 
<i>pthread_join()</i>
function will fail if:
<dl compact>

<dt>[EINVAL]<dd>
The implementation has detected that the value specified by
<i>thread</i>
does not refer to a joinable thread.

<dt>[ESRCH]<dd>
No thread could be found corresponding to that specified
by the given thread ID.

</dl>
<p>
The
<i>pthread_join()</i>
function may fail if:
<dl compact>

<dt>[EDEADLK]<dd>A deadlock was detected or
the value of
<i>thread</i>
specifies the calling thread.

</dl>
<p>
The
<i>pthread_join()</i>
function will not return an error code of [EINTR].
</blockquote><h4><a name = "tag_000_007_1383">&nbsp;</a>EXAMPLES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_007_1384">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_007_1385">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_007_1386">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="pthread_create.html">pthread_create()</a></i>,
<i><a href="wait.html">wait()</a></i>,
<i><a href="pthread.h.html">&lt;pthread.h&gt;</a></i>.
</blockquote><h4>DERIVATION</h4><blockquote>
Derived from the POSIX Threads Extension (1003.1c-1995)
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>

